library(here)
library(data.table)
library(ggplot2)
library(cowplot)

# Load competition data -------------------------------------------------------------

fullData <- fread(here('data', 'full_rol.csv'))

ggplot(fullData[ , .(total = sum(ml),
                     mean = mean(ml)), by = year],
       aes(x = year, y = total)) +
  geom_bar(stat = 'identity', fill ='darkgrey') +
  geom_line(aes(y = mean*75), size = 2, color = 'black') +
  scale_y_continuous(expand = expansion(mult = c(0, 0.03)),
                     breaks = seq(0, 75, 15),
                     sec.axis = sec_axis(trans = ~./75,
                                         breaks = seq(0, 1, .2),
                                         labels = scales::percent)) +
  scale_x_continuous(breaks = seq(1985, 2020, 5)) +
  labs(x = element_blank(), 
       y = element_blank()) +
  theme_cowplot(font_size = 14) +
  theme(panel.grid.major.y = element_line(linetype = "dotted"))

ggsave(here('output', 'figures', 'figure-2.pdf'),
       height = 4, width = 6, units = 'in')